<!-- 强势新品 -->
<template>
  <div class="products1">
    <div class="container">
      <!-- 标题 -->
      <div class="title">
        <h3>强势新品</h3>
        <span>新品好货一网打尽</span>
      </div>
      <!-- 产品展示 -->
      <div class="products-box">
        <div
          class="box"
          v-for="item in boxList"
          :key="item.id"
          @click="jump(item)"
        >
          <img :src="item.s_goods_photos[0].path" alt="" />
          <div class="box-info">
            <p>{{ item.name }}</p>
            <p>{{ item.desc }}</p>
            <p>￥{{ item.price }}</p>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  data() {
    return {
      boxList: [],
    };
  },
  methods: {
    // 点击商品跳转
    jump(item) {
      this.$router.push({
        path: "/detail",
        query: {
          id: item.id,
        },
      });
    },
  },
  created() {
    // 获取商品信息
    axios({
      method: "GET",
      url: "http://shop.bluej.cn/api/goods",
      params: {
        project_id: 90,
        status: 1,
        classify_id: 802,
      },
    })
      .then((res) => {
        // 接口获取的数组为倒序
        this.boxList = res.data.result.rows.reverse();
      })
      .then((err) => {
        // console.log(err);
      });
  },
};
</script>

<style lang="scss" scoped>
.products1 {
  width: 100%;
  min-width: 1200px;
  height: 434px;
  margin: 40px auto;
  .container {
    width: 1200px;
    .title {
      width: 100%;
      height: 32px;
      h3 {
        font-size: 24px;
        line-height: 32px;
        color: #333;
        float: left;
        font-weight: 400;
      }
      span {
        font-size: 14px;
        line-height: 32px;
        color: #666;
        float: left;
        margin-left: 16px;
      }
    }
    .products-box {
      width: 100%;
      height: 382px;
      margin-top: 20px;
      .box {
        width: 400px;
        height: 184px;
        float: left;
        margin: 0 0 14px 14px;
        position: relative;
        background-color: #fff;
        display: block;
        cursor: pointer;
        &:hover {
          box-shadow: 0 4px 20px 0 rgb(0 0 0 / 15%);
        }
        &:first-child {
          width: 372px;
          height: 382px;
          margin: 0;
          position: relative;
          text-align: center;
          background-color: #fff;
          padding-top: 30px;
          box-sizing: border-box;
          img {
            width: 200px;
            height: 200px;
            display: block;
            margin: 0 auto;
            float: none;
          }
          .box-info {
            transform: translateX(-50%);
            position: absolute;
            top: 60%;
            left: 50%;
            p {
              text-align: center;
            }
          }
        }
        img {
          width: 120px;
          height: 120px;
          float: left;
          margin: 32px 24px;
        }
        .box-info {
          position: absolute;
          top: 50%;
          left: 168px;
          transform: translateY(-50%);
          p {
            text-align: left;
            font-size: 14px;
            line-height: 20px;
            &:nth-child(1) {
              border: 1px solid #0096ff;
              margin: 20px auto 12px;
              font-size: 14px;
              color: #0096ff;
              line-height: 18px;
              display: inline-block;
              padding: 3px 8px;
              font-weight: 700;
            }
            &:nth-child(2) {
              font-size: 12px;
              color: #666;
              line-height: 18px;
              margin: 4px 10px;
            }
            &:nth-child(3) {
              color: #ff3232;
              margin: 4px 10px;
            }
          }
        }
      }
    }
  }
}
</style>
